﻿package com.gengine.core.frame
{
    import flash.events.*;
    import flash.utils.*;

    class TimerFrame extends Frame
    {
        private var _timer:Timer;
        private var _startTimer:int;
        private var _delayConst:int = 100;
        private var _accruedTime:int;

        function TimerFrame(param1:Number = 1)
        {
            super(param1 * 1000);
            this._timer = new Timer(this._delayConst);
            return;
        }// end function

        override public function play() : void
        {
            super.play();
            this._timer.addEventListener(TimerEvent.TIMER, this.onEnterFrameHandler);
            this._startTimer = getTimer();
            this._accruedTime = 0;
            this._timer.start();
            return;
        }// end function

        override protected function onEnterFrameHandler(event:Event = null) : void
        {
            var _loc_2:* = getTimer();
            this._accruedTime = this._accruedTime + (_loc_2 - this._startTimer);
            if (this._accruedTime >= delay)
            {
                renderer(this._accruedTime);
                this._accruedTime = this._accruedTime - delay;
            }
            this._startTimer = getTimer();
            return;
        }// end function

        override public function stop() : void
        {
            super.stop();
            this._timer.stop();
            this._timer.removeEventListener(TimerEvent.TIMER, this.onEnterFrameHandler);
            return;
        }// end function

    }
}
